import {Component, OnInit, Inject, ViewChild} from '@angular/core';
import {User} from '../../models/User';
import {AssetService} from '../../service/AssetService';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
import {Asset} from '../../models/Asset';
import { Deliver } from '../../models/Deliver';
import {DeliverService} from '../../service/DeliverService';

@Component({
  templateUrl: './assignHistory.html',
  styleUrls: ['./assignHistory.css']
})
export class AssignHistoryComponent implements OnInit {
  cols = ['oldMaster', 'deliverPerson', 'deliverDate'];
  assetInfo: Asset;
  delivers: Deliver[];
  constructor(
    private dialogRef: MatDialogRef<AssignHistoryComponent>,
    private  deliverService: DeliverService,
    // users：下拉框
    // asset: 要展示的值
    @Inject(MAT_DIALOG_DATA) public data: {asset: Asset}
  ) {
    this.assetInfo =  data.asset;
  }
  ngOnInit() {
    this.deliverService.getList(this.assetInfo.id).subscribe( (list: { res: Deliver[], success: boolean, total: number}) => {
      this.delivers = list.res;
    });
  }
  trackById(index: number, item: any) {
    return item.id;
  }
}
